home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Misc / msql-1.0.6 / src / tests / rtest < prev   
Text File  |  1995-01-04  |  2KB  |  100 lines

  1. #!/bin/sh
  2. # Regression tester for mSQL.
  3. #
  4. # This script just drives the individual tests in the rtest.src
  5. # directory.  Run it as "rtest <db>" where db is the name of a database.
  6. # The database will be created and destroyed during the testing so don't
  7. # use anything that already exists (the scripts wont let you anyway).
  8. #
  9. #                        bambi.
  10.  
  11. # If you want to do the testing on a machine other than the local box
  12. # (or you want to force a TCP connection) set the variable below to the
  13. # hostname of the box running the server
  14. #
  15. #MSQLHOST= -h Some.Other.Host
  16.  
  17.  
  18. # Do not uncomment this variable.  It is used to reset the test results
  19. # after a major change to the test suite or output format of msql
  20. #RESET=1
  21.  
  22. DB=$1
  23.  
  24. if test "$DB." = "."
  25. then
  26.     echo
  27.     echo "Bad usage.  Read the intro to the script for details!"
  28.     echo
  29.     exit 1
  30. fi
  31.  
  32. #
  33. # How can we echo without a newline?
  34. #
  35. if echo '\c' | grep -s c >/dev/null 2>&1
  36. then
  37.         ECHO_N="echo -n"
  38.         ECHO_C=""
  39. else
  40.         ECHO_N="echo"
  41.         ECHO_C='\c'
  42. fi
  43.  
  44. #
  45. # Find out the names of the tests
  46. #
  47. cd rtest.src
  48. TESTS=`ls [0-9]*.test | sort -n | sed "s/\.test\$//"`
  49. rm -f *.res
  50. COUNT=0
  51.  
  52. #
  53. # Setup a clean database
  54. #
  55. echo "y" | ../../msql/msqladmin drop $DB > /dev/null
  56. ../../msql/msqladmin create $DB
  57. if test $? -ne 0
  58. then
  59.     echo
  60.     echo
  61.     echo "Couldn't setup new database for testing."
  62.     echo
  63.     exit 1
  64. fi
  65.  
  66. #
  67. # Run through the tests and bail out if there's an error.
  68. #
  69. echo
  70. echo "Starting tests."
  71. for I in $TESTS
  72. do
  73.     $ECHO_N ".$ECHO_C"
  74.     if test "$RESET." = "."
  75.     then
  76.         ../../msql/msql $MSQHOST $DB < $I.test > $I.res 2>&1
  77.         diff $I.out $I.res > /dev/null
  78.         if test $? -ne 0 
  79.         then
  80.             echo
  81.             echo
  82.             echo "ERROR : Regression test failed on test \"$I\"."
  83.             echo "Test results have been saved in rtest.src/*.res"
  84.             echo
  85.             exit 1
  86.         fi
  87.     else
  88.         ../../msql/msql $MSQHOST $DB < $I.test > $I.out 2>&1
  89.     fi
  90.     COUNT=`expr $COUNT + 1`
  91. done
  92.  
  93. echo
  94. echo
  95. echo "All $COUNT tests have passed"
  96. echo "Results of the individual tests can be found in rtest.src/*.res"
  97. echo
  98. exit 0
  99.